home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 514 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  54 lines

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: "brian (b.c.) white" <bcwhite@bnr.ca>
  3. Newsgroups: comp.std.c++
  4. Subject: Problem with template overloading
  5. Date: 18 Feb 1996 02:14:29 GMT
  6. Organization: Bell-Northern Research Ltd.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4g40t8$kpq@bcarh8ab.bnr.ca>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. Content-Type: text
  11. X-Nntp-Posting-Host: bcarsd26.bnr.ca 
  12. Content-Length: 902
  13. Originator: clamage@taumet
  14.  
  15.  
  16. Is it allowed to overload template names based on their parameters
  17. in the same way that functions can be overloaded?
  18.  
  19. I tried to create two versions of the same class name as such:
  20.  
  21. template <class C>
  22. class A {
  23.     [...]
  24. };
  25.  
  26. template <class C1, class C2>
  27. class A {
  28.     [...]
  29. };
  30.  
  31.  
  32. Gcc 2.7.2 gives errors about redefinition even though, as far as I can
  33. tell, these names are distinct.
  34.  
  35. test.cc:8: declaration of template `template <class C1, class C2> class A'
  36. test.cc:2: conflicts with previous declaration `template <class C> class A'
  37.  
  38. In the end, I had to create two classes: A1 and A2.
  39.  
  40. Is this a problem with GCC or does the standard not allow it?
  41.  
  42.                                         Brian
  43.                                  ( bcwhite@bnr.ca )
  44.  
  45. -------------------------------------------------------------------------------
  46.     In theory, theory and practice are the same.  In practice, they're not.
  47.  
  48. [ To submit articles: Try just posting with your newsreader.  If that fails,
  49.               use mailto:std-c++@ncar.ucar.edu
  50.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  51.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  52.   Comments? mailto:std-c++-request@ncar.ucar.edu
  53. ]
  54.